////////////////////////////////////////////////////////////////////////////////
// This file is part of the Mist compiler.                                    //
//                                                                            //
// Copyright (C) 2008, 2009 The Mist project                                  //
//                                                                            //
// For a list of contributors, see the COMMITTERS file.                       //
//                                                                            //
// The Mist compiler is free software: you can redistribute it and/or modify  //
// it under the terms of the GNU General Public License as published by       //
// the Free Software Foundation, either version 3 of the License, or          //
// (at your option) any later version.                                        //
//                                                                            //
// The Mist compiler is distributed in the hope that it will be useful,       //
// but WITHOUT ANY WARRANTY; without even the implied warranty of             //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              //
// GNU General Public License for more details.                               //
//                                                                            //
// You should have received a copy of the GNU General Public License          //
// in the COPYING file. If not, see <http://www.gnu.org/licenses/>.           //
////////////////////////////////////////////////////////////////////////////////

///
/// \file
/// Contains the AccessType class and related functions.
///

#ifndef ACCESSTYPE_HPP
#define ACCESSTYPE_HPP

////////////////////////////////////////////////////////////////////////////////
// Includes                                                                   //
////////////////////////////////////////////////////////////////////////////////

#include <string>
using std::string;

////////////////////////////////////////////////////////////////////////////////
// AccessType Enum                                                            //
////////////////////////////////////////////////////////////////////////////////

/// Specifies whether an expression can be read from and/or written to.
///
class AccessType {
	public:
		
		/// Construct an accesstype, without anything initialized.
		/// Any such accesstype must of course be initialized before
		/// being read.
		///
		AccessType() {}
		
		/// Construct an accesstype.
		///
		AccessType(
			bool r, ///< read-access
			bool w, ///< write-access
			bool l  ///< logical, assertion access only
		);
		
		/// Specifies whether read-access is available.
		///
		bool readable;
		
		/// Specifies whether write-access is available.
		///
		bool writable;
		
		/// Specifies whether access is limited to assertions.
		///
		bool logical;
};

////////////////////////////////////////////////////////////////////////////////
// Convenience Functions                                                      //
////////////////////////////////////////////////////////////////////////////////

/// \return \a accessType converted to a string; one of "n", "r", "w", "rw", "l"
///
/// \relates AccessType
///
string to_string(AccessType accessType);

/// 
///
bool operator==(const AccessType& a, const AccessType& b);

/// 
///
bool operator!=(const AccessType& a, const AccessType& b);

#endif // ACCESSTYPE_HPP
